<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // (?.) 表示 判断前面的值有没有传入  当我们应对对象类型的参数的时候
        function main(config){
            // const dbHost = config && config.db && config.db.host
            const dbHost = config?.db?.host
            console.log(dbHost);
        }
        main({
            db: {
                host: '192.168.1.100',
                username: 'root'
            },
            catch: {
                host: '192.168.1.200',
                username: 'admin'
            }
        })
    </script>
</body>
</html>